home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 March
/
EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso
/
earcd
/
comm2
/
rmvnwsgr.lha
/
RemoveNewsGroup
/
RemoveNewsGroup.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1995-09-01
|
3KB
|
124 lines
/* RemoveNewsGroup - v1.0 - 31-Aug-95 - by Jim McKinney */
/* An ARexx program that will totally remove a newsgroup from your system.
First it removes the postings in a newsgroup and deletes its directories.
It then updates your Active files and .tinrc. RemoveNewsGroup expects
newsgroups to be found in the UUNews: directory. Enjoy! */
/* Open rexx.support library */
lib = 'rexxsupport.library'
if ~show('l', lib) then do
if ~addlib(lib, 0, -30, 0) then do
say 'Unable to open' lib
exit 10
end
end
/* Check input */
x = arg()
if x == 0 | x > 1 then do
say 'USAGE: RemoveNewsGroup <news.group.name>'
exit 10
end
/* Slice and dice newsgroup name */
groupname = arg(1)
say 'Removing "' || groupname || '" posts and directory structure.'
start = 1 ; stop = length(groupname) ; x = 1
do while start < stop
i = pos('.', groupname, start)
if i == 0 then i = stop + 1
name = 'name' || x || ' = substr(groupname, start, i - start)'
interpret name
start = i + 1 ; x = x + 1
end
x = x - 1
/* Build path string */
pathname = ''
do i = 1 for x
name = 'pathname = pathname || name' || i || '|| "/"'
interpret name
end
pathname = pathname || #?
pragma('d','UUNews:') /* Get in the right directory */
/* Delete posts and empty directories */
address command 'Delete >nil:' pathname
i = lastpos('/', pathname)
do while i > 0
pathname = left(pathname, i - 1)
i = lastpos('/', pathname)
list = showdir(pathname, 'd')
if list == '' then address command 'Delete' pathname
end
/* Update "Active" file */
fileName = 'UUNews:Active' ; inFile = 'ifile' ; outFile = 'ofile' ; tempFile = 't:RNG-temp'
call openFiles
call readWrite
call closeFiles
call updateOld
/* Now let's fix "PurgeFile" */
fileName = 'UUNews:PurgeFile'
call openFiles
call readWrite
call closeFiles
call updateOld
/* This last part is for tin. Remove it if you don't use tin. */
/* Fix .newsrc. Assumes $HOME is AmiTCP: */
fileName = 'AmiTCP:.newsrc'
call openFiles
call readWrite
call closeFiles
call updateOld
exit /* All done!!! */
/* My functions begin here */
/* Open files function */
openFiles:
say 'Updating "' || fileName || '"'
if ~open(inFile, fileName, 'r') then do
say 'Error opening "' || fileName || '" file.'
exit 20
end
if ~open(outFile, tempFile, 'w') then do
say 'Error opening "' || tempFile || '" file.'
exit 20
end
return
/* Read from input file and write output function */
readWrite:
do forever
line = readln(inFile)
if eof(inFile) then leave
if ~abbrev(line, groupname) then writeln(outFile, line)
end
return
/* Close files function */
closeFiles:
if ~close(inFile) then do
say 'Error closing "' || fileName || '" file.'
exit 20
end
if ~close(outFile) then do
say 'Error closing "' || tempFile || '" file.'
exit 20
end
return
/* Update files function. Let AmigaDOS handle the file actions */
updateOld:
address command "Delete >nil:" fileName
address command "Copy" tempFile fileName
address command "Delete >nil:" tempFile
return